//
//  LikeHeadImgView.m
//  TheRoadAD
//
//  Created by baixue on 16/8/15.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "LikeHeadImgView.h"

@implementation LikeHeadImgView


//-(NSArray *)headImg{
//    if (!_headImg) {
//        _headImg = [NSArray array];
//    }
//    return _headImg;
//}

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setLikeHeadImg];
//        [self setHeadImage];
    }
    return self;
}
// 粉丝关注的头像列表
-(void)setLikeHeadImg{
    // 分享按钮
    UIButton *share = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:share];
    [share setImage:[UIImage imageNamed:@"tabBar_publish_icon"] forState:UIControlStateNormal];
    share.sd_layout
    .topSpaceToView(self,1)
    .leftEqualToView(self)
    .widthIs(30)
    .heightIs(30);
    
    UIButton *location = [UIButton buttonWithType:UIButtonTypeCustom];
    [self addSubview:location];
    [location setImage:[UIImage imageNamed:@"tabBar_publish_icon"] forState:UIControlStateNormal];
    location.sd_layout
    .topSpaceToView(self,1)
    .leftSpaceToView(share,10)
    .widthIs(30)
    .heightIs(30);
    
    
}

- (void)layoutSubviews{
    [super layoutSubviews];
    NSMutableArray *arr = [NSMutableArray array];
    
    for (NSInteger i = 0; i < _headImg.count; i++) {
        
        UIImageView *heaImg = [[UIImageView alloc] init];
        heaImg.image = [UIImage imageNamed:_headImg[i]];
        [arr addObject:heaImg];
        [self addSubview:heaImg];
        heaImg.frame = CGRectMake(80 + 40 * i, 1, 30 , 30);
        if (80+40*(i + 1) > self.frame.size.width) {
            heaImg.hidden = YES;
            UIImageView *endImage = [[UIImageView alloc] init];
            endImage.image = [UIImage imageNamed:@"shenglue"];
            [self addSubview:endImage];
            endImage.frame = CGRectMake(80 + 40 * (i -1), 1, 30 , 30);
            [arr[i - 1] setHidden:YES];
            return;
        }

    }
    
}

@end
